import Vue from 'vue';
import Router from 'vue-router';
import parentView from '@/components/parent-view';
//路由添加规则--liqing
//菜单路由:作为菜单的路由配置(首页，资源等),菜单页路由与homer保持同级，配置参考(homer,resourceManagement)等
//非菜单路由:不作为菜单的路由配置(新建，修改，详情页等)，非菜单页路由需配置在路由parentView下，配置参考(creatImage、experdetails)等
//添加菜单路由后，需要在数据库添加对应菜单数据(数据库的url值与菜单的name值保持一致)，添加完数据后，登录管理平台进入菜单及logo管理修改一下任意菜单，菜单才会显示
//非菜单页需要在meta中配置activeName参数，activeName为当前匹配菜单name
//不要共用非菜单页（activeName(匹配菜单)无法设置）,如果公用非菜单页，（activeName(匹配菜单设置为数组形式),并在跳转路由的时候配置query对象中expType字段，值为activeName数组中对应值的序号）

//如果项目需要使用固定的菜单（显示隐藏和菜单显示名称不受后台配置数据控制），在此页面为菜单页添加hidden参数配置（true为显示，false为隐藏,与name同级），删除main页面的菜单处理逻辑
// const main = () => import('@/view/main/trainmain.vue');
Vue.use(Router);
// 获取原型对象上的push函数
const originalPush = Router.prototype.push;
// 修改原型对象中的push方法，避免路由重复时控制台报错
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch((err) => err);
};

export default new Router({
  mode: 'hash',
  // // 👇 __MICRO_APP_BASE_ROUTE__ 为micro-app传入的基础路由
  // base: window.__MICRO_APP_BASE_ROUTE__ || process.env.BASE_URL,

  routes: [
    {
      path: '/',
      redirect: '/main',
      // component: main,
      meta: {
        requireAuth: false
      }
    },
    {
      path: '/main',
      name: 'main',
      meta: {
        requireAuth: true
      },
      component: (resolve) => {
        //('@/view/main/trainmain.vue')
        require(['@/view/main/main.vue'], resolve)
      },
      children: [
        //菜单路由通过后台数据动态生成，在designer_menu配置
        // 放单页面(非菜单页)
        {
          path: '/parentView',
          name: 'parentView',
          title: '单页面',
          component: parentView,
          meta: {
            requireAuth: true,
            mark: false,
            defClass: 'com-icon-def-s',
            activeClass: 'com-icon-active-s',
            bg: 'bgMain'
          },
          children: [


          {
              path: '/teacherClassDetail',
              name: 'teacherClassDetail',
              component: (resolve) => {
                  require(['@/view/teaching/components/classDetail.vue'], resolve)
                  // D:\workspace\beiyou\beiyou\src\view\teaching\components\classDetail.vue
              },
              //
              meta: {
                  title: '试卷',
                  requireAuth: true,
                  mark: false,
                  defClass: 'com-icon-def-s',
                  activeClass: 'com-icon-active-s',
                  bg: 'bgMain'
              }
          },
              
              
              
              
              
            {
              path: '/testPaper',
              name: 'testPaper',
              component: (resolve) => {
                require(['@/view/experimentalScene/examPlan/testPaper.vue'], resolve)
              },
              meta: {
                title: '试卷',
                requireAuth: true,
                mark: false,
                defClass: 'com-icon-def-s',
                activeClass: 'com-icon-active-s',
                bg: 'bgMain'
              }
            },
            {
              path: '/questionBank',
              name: 'questionBank',
              component: (resolve) => {
                require(['@/view/resourceManagement/questionBank.vue'], resolve)
              },
              meta: {
                title: '试题管理',
                requireAuth: true,
                mark: false,
                defClass: 'com-icon-def-s',
                activeClass: 'com-icon-active-s',
                bg: 'bgMain'
              }
            },

            {
              path: '/testPaperDetail',
              name: 'testPaperDetail',
              component: (resolve) => {
                require(['@/view/experimentalScene/examPlan/testPaperDetail.vue'], resolve)
              },
              meta: {
                title: '创建试卷',
                show: false,
                requireAuth: true,
                mark: false,
                defClass: 'com-icon-def-s',
                activeClass: 'com-icon-active-s',
                bg: 'bgMain'
              }
            },

            // {
            //     path: '/icon',
            //     name: 'icon',
            //     component: (resolve) => {
            //         require(['@/view/resourceManagement/icon.vue'], resolve);
            //     },
            //     meta: {
            //         title: '图标',
            //         requireAuth: true,
            //         mark: false,
            //         defClass: 'com-icon-def-s',
            //         activeClass: 'com-icon-active-s',
            //         bg: 'bgMain'
            //     },
            // },
            {
              path: '/creatIcon',
              name: 'creatIcon',
              component: (resolve) => {
                require(['@/components/creatPage/creatIcon.vue'], resolve)
              },
              meta: {
                show: false,
                title: '创建图标',
                activeName: 'icon'
              }
            },

            {
              path: '/creatGroup',
              name: 'creatGroup',
              title: '创建实验组',
              component: (resolve) => {
                require(['@/components/creatPage/creatGroup.vue'], resolve)
              },
              meta: {
                activeName: 'experGroup'
              }
            },
            {
              path: '/creatRoleGroup',
              name: 'creatRoleGroup',
              title: '创建角色组',
              component: (resolve) => {
                require(['@/components/creatPage/creatRoleGroup.vue'], resolve)
              },
              meta: {
                activeName: 'role'
              }
            },
            {
              path: '/questionnaireUser',
              name: 'questionnaireUser',
              title: '问卷用户',
              component: (resolve) => {
                require(['@/components/creatPage/questionnaireUser.vue'], resolve)
              },
              meta: {
                activeName: 'questionnaireSurvey'
              }
            },
            {
              path: '/section',
              name: 'section',
              title: '段落管理',
              component: (resolve) => {
                require(['@/components/creatPage/section.vue'], resolve)
              },
              meta: {
                activeName: 'guide'
              }
            },
            {
              path: '/markdownEdit',
              name: 'markdownEdit',
              title: 'md文件编辑',
              component: (resolve) => {
                require(['@/components/creatPage/markdownEdit.vue'], resolve)
              },
              meta: {
                activeName: 'guide'
              }
            },

            {
              path: '/guide',
              name: 'guide',
              component: (resolve) => {
                require(['@/view/resourceManagement/guide.vue'], resolve)
              },
              meta: {
                title: '指导书',
                requireAuth: true,
                mark: false,
                defClass: 'com-icon-def-s',
                activeClass: 'com-icon-active-s',
                bg: 'bgMain'
              }
            },

            {
              path: '/exam',
              name: 'exam',
              component: (resolve) => {
                require(['@/view/experimentalScene/examPlan/exam.vue'], resolve)
              },
              meta: {
                title: '考试',
                requireAuth: true,
                mark: false,
                defClass: 'com-icon-def-s',
                activeClass: 'com-icon-active-s',
                bg: 'bgMain'
              }
            },
            // {
            //     path: '/courseware',
            //     name: 'courseware',
            //     component: (resolve) => {
            //         require(['@/view/resourceManagement/courseware.vue'], resolve);
            //     },
            //     meta: {
            //         title: '课件管理',
            //         requireAuth: true,
            //         mark: false,
            //         defClass: 'com-icon-def-s',
            //         activeClass: 'com-icon-active-s',
            //         bg: 'bgMain'
            //     },
            // },

            {
              path: '/creatExper',
              name: 'creatExper',
              component: (resolve) => {
                require(['@/view/experimentalScene/designPanel/creatExp/edit.vue'], resolve)
              },
              meta: {
                title: '构建课件',
                show: false,
                requireAuth: true,
                mark: false,
                defClass: 'com-icon-def-s',
                activeClass: 'com-icon-active-s',
                bg: 'bgMain'
              }
            },

            // 新排课
            {
              path: '/courseScheduleDetail/:id',
              name: 'courseScheduleDetail',
              component: (resolve) => {
                require([
                  '@/view/experimentalScene/schedulePlan/trainDetail.vue'
                  // '@/view/experimentalScene/schedulePlan/courseScheduleDetail.vue' // old
                ], resolve)
              },
              meta: {
                requireAuth: true,
                activeName: 'class'
                // isAccess: ['homer']
              }
            },

            {
              path: '/videoLearn',
              name: 'videoLearn',

              component: (resolve) => {
                require(['@/view/resourceManagement/videoLearn.vue'], resolve)
              },
              meta: {
                title: '视频自学',
                requireAuth: true,
                mark: false,
                defClass: 'com-icon-def-s',
                activeClass: 'com-icon-active-s',
                bg: 'bgMain'
              }
            },

            {
              path: '/creatLearnVideo',
              name: 'creatLearnVideo',
              component: (resolve) => {
                require(['@/components/creatPage/creaLearnVideo.vue'], resolve)
              },
              meta: {
                title: '创建理论课件',
                show: false,
                requireAuth: true,
                mark: false,
                defClass: 'com-icon-def-s',
                activeClass: 'com-icon-active-s',
                bg: 'bgMain'
              }
            },
            {
              path: '/class',
              name: 'class',

              component: (resolve) => {
                // 新教学班
                require(['@/view/experimentalScene/schedulePlan/myClass.vue'], resolve)
              },
              meta: {
                title: '教学管理',
                requireAuth: true,
                mark: false,
                defClass: 'com-icon-def-s',
                activeClass: 'com-icon-active-s',
                bg: 'bgMain'
              }
            },
            {
              path: '/staticticsDetail',
              name: 'staticticsDetail',
              title: '学习详情',
              component: (resolve) => {
                require(['@/view/experimenterTrack/experHomer.vue'], resolve)
              },
              meta: {
                requireAuth: true,
                activeName: 'expTrack',
                isAccess: ['expTrack']
              }
            },
            {
              path: '/creatCourse',
              name: 'creatCourse',
              component: (resolve) => {
                require(['@/components/creatPage/createCourse.vue'], resolve)
              },
              meta: {
                title: '创建课程',
                show: false,
                requireAuth: true,
                mark: false,
                defClass: 'com-icon-def-s',
                activeClass: 'com-icon-active-s',
                bg: 'bgMain'
              }
            },

            {
              path: '/section',
              name: 'section',
              component: (resolve) => {
                require(['@/components/creatPage/section.vue'], resolve)
              },
              meta: {
                title: '段落管理',
                show: false,
                requireAuth: true,
                mark: false,
                defClass: 'com-icon-def-s',
                activeClass: 'com-icon-active-s',
                bg: 'bgMain'
              }
            },

            {
              path: '/experdetails',
              name: 'experdetails',
              component: (resolve) => {
                require(['@/view/experimentalScene/designPanel/experdetails.vue'], resolve)
              },
              meta: {
                title: '创建课程',
                show: false,
                requireAuth: true,
                mark: false,
                defClass: 'com-icon-def-s',
                activeClass: 'com-icon-active-s',
                bg: 'bgMain'
              }
            },
            {
              path: '/coursedetails',
              name: 'coursedetails',
              title: '课程详情页',
              component: (resolve) => {
                require(['@/view/experimentalScene/designPanel/coursedetails.vue'], resolve)
              },
              meta: {
                activeName: 'course'
              }
            },

     
            {
              path: '/reportPage',
              name: 'reportPage',
              title: '审核报告',
              component: (resolve) => {
                require(['@/view/referee/reportPage.vue'], resolve)
              },
              meta: {
                activeName: 'referee'
              }
            },
            {
              path: '/monitoring',
              name: 'monitoring',
              title: '选手行为监控',
              component: (resolve) => {
                require(['@/view/referee/monitoring.vue'], resolve)
              },
              meta: {
                activeName: 'referee'
              }
            },


            {
              path: '/test-markdown',
              name: 'test-markdown',
              title: '测试Markdown',
              component: (resolve) => {
                require(['@/view/resourceManagement/test-markdown/test-markdown.vue'], resolve)
              }
            },
          ]
        }
      ]
    },
    {
      path: '/login',
      name: 'login',
      title: '登录页',
      component: (resolve) => {
        require(['@/view/login/Homer.vue'], resolve)
      },
      meta: {
        requireAuth: false,
        login: true
      }
    },

    // 新窗口页面

    {
      path: '/testMachine',
      name: 'testMachine',
      title: '试验机',
      component: (resolve) => {
        require(['@/components/testMachine/testMachine.vue'], resolve)
      }
    },

    {
      path: '/knowledgeCompe',
      name: 'knowledgeCompe',
      title: '试验机',
      component: (resolve) => {
        require(['@/view/knowledge-compete/KnowledgeCompetition/KnowledgeCompetition.vue'], resolve)
      }
    },


      
    {
      path: '/mdPreview',
      name: 'mdPreview',
      title: 'md文档预览',
      component: (resolve) => {
        require(['@/components/creatPage/mdPreview.vue'], resolve)
      }
    },
    {
      path: '/testScreen',
      name: 'testScreen',
      title: '试验机',
      component: (resolve) => {
        require(['@/view/experimentalScene/schedulePlan/testMachine.vue'], resolve)
      }
    },
    {
      path: '/transfer',
      name: 'transfer',
      title: '中转页面',
      component: (resolve) => {
        require(['@/components/transfer/transfer.vue'], resolve)
      },
      meta: {
        requireAuth: false
      }
    },
    {
      path: '/transferPage',
      name: 'transferNew',
      title: '中转页面',
      component: (resolve) => {
        require(['@/components/transfer/transfer-new.vue'], resolve)
      },
      meta: {
        requireAuth: false
      }
    },
    {
      path: '/assessmentReport',
      name: 'assessmentReport',
      title: '操作员评估报告',
      component: (resolve) => {
        require(['@/view/experimenterTrack/assessmentReport.vue'], resolve)
      },
      meta: {
        requireAuth: true
      }
    },
    {
      path: '/statisticalReport',
      name: 'statisticalReport',
      title: '综合统计报告',
      component: (resolve) => {
        require(['@/view/experimenterTrack/statisticalReport.vue'], resolve)
      },
      meta: {
        requireAuth: true
      }
    },
    {
      path: '/trainReport',
      name: 'trainReport',
      title: '训练报告',
      component: (resolve) => {
        require(['@/view/train/components/report.vue'], resolve)
      }
    },
    {
      path: '/ControlPage',
      name: 'transferQax',
      title: '中转控制页面',
      component: (resolve) => {
        require(['@/components/transfer/qax-transfer.vue'], resolve)
      },
      meta: {
        requireAuth: false
      }
    },
    {
      path: '/archiveExamReports',
      name: 'archiveExamReports',
      title: '归档考试报告',
      component: (resolve) => {
        require(['@/view/experimenterTrack/archive-reports/archiveExamReports.vue'], resolve)
      }
    },
    {
      path: '/archiveAdcReportNew',
      name: 'archiveAdcReportNew',
      title: '归档竞赛adc报告',
      component: (resolve) => {
        require(['@/view/experimenterTrack/archive-reports/archiveAdcReportNew.vue'], resolve)
      }
    },
    {
      path: '/archiveCtfReport',
      name: 'archiveCtfReport',
      title: '归档夺旗赛报告',
      component: (resolve) => {
        require(['@/view/experimenterTrack/archive-reports/archiveCtfReportNew.vue'], resolve)
      }
    },
    {
      path: '/archiveKcReport',
      name: 'archiveKcReport',
      title: '归档知识赛报告',
      component: (resolve) => {
        require(['@/view/experimenterTrack/archive-reports/archiveKcReport.vue'], resolve)
      }
    },
    {
      path: '/archiveAwdReportNew',
      name: 'archiveAwdReportNew',
      title: '归档对抗演练报告',
      component: (resolve) => {
        require(['@/view/experimenterTrack/archive-reports/archiveAwdReportNew.vue'], resolve)
      }
    },
    {
      path: '/archiveStReportNew',
      name: 'archiveStReportNew',
      title: '归档渗透演练报告',
      component: (resolve) => {
        require(['@/view/experimenterTrack/archive-reports/archiveStReportNew.vue'], resolve)
      }
    },
    {
      path: '/archiveZhReportNew',
      name: 'archiveZhReportNew',
      title: '归档综合演练报告',
      component: (resolve) => {
        require(['@/view/experimenterTrack/archive-reports/archiveZhReportNew.vue'], resolve)
      }
    },
    {
      path: '/archiveHwReportNew',
      name: 'archiveHwReportNew',
      title: '归档护网演练报告',
      component: (resolve) => {
        require(['@/view/experimenterTrack/archive-reports/archiveHwReportNew.vue'], resolve)
      }
    },
    {
      path: '/archiveStatisticalReport',
      name: 'archiveStatisticalReport',
      title: '个人综合报告',
      component: (resolve) => {
        require(['@/view/experimenterTrack/archive-reports/archiveStatisticalReport.vue'], resolve)
      }
    },
    {
      path: '/verificationPage',
      name: 'verificationPage',
      title: '验证界面',
      component: (resolve) => {
        require(['@/view/common/verification-page.vue'], resolve)
      },
      meta: {
        requireAuth: true
      }
    }
  ]
})
